home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 2 / CU Amiga Magazine's Super CD-ROM 02 (1996)(EMAP Images)(GB)[!][issue 1996-04].iso / magazine / amiga_e / amigae.sept.archive / 000064_crash!MSUVX1.M….EDU!UMLANGSTON_Sat, 25 Sep 93 02:47:46 PST.msg < prev    next >
Text File  |  1993-11-02  |  2KB  |  63 lines

  1. Received: by bkhouse.cts.com (V1.16/Amiga)
  2.     id AA00000; Sat, 25 Sep 93 02:47:46 PST
  3. Received: from msuvx1.memst.edu by crash.cts.com with smtp
  4.     (Smail3.1.28.1 #18) id m0ogKly-0000OFC; Fri, 24 Sep 93 14:33 PDT
  5. Received: from MSUVX1.MEMST.EDU by MSUVX1.MEMST.EDU (PMDF V4.2-14 #3869) id
  6.  <01H3BZYXK3UO9KNLOE@MSUVX1.MEMST.EDU>; Fri, 24 Sep 1993 16:36:30 CST
  7. Date: Fri, 24 Sep 1993 16:36:30 -0600 (CST)
  8. Message-id: <01H3BZYXLG369KNLOE@MSUVX1.MEMST.EDU>
  9. X-VMS-To: IN%"amigae@bkhouse.cts.com"
  10. MIME-version: 1.0
  11. Content-type: TEXT/PLAIN; CHARSET=US-ASCII
  12. Content-transfer-encoding: 7BIT
  13. From: UMLANGSTON@MSUVX1.MEMST.EDU
  14. To: amigae@bkhouse.cts.com
  15. Subject: Random numbers
  16.  
  17. Okay people, I have a problem.
  18.  
  19.   I'm tryring to generate random numbers.  Here's the story:
  20. Using code that Barry supplied, I have a 2D matrix, 500x70, set up.  I
  21. want to go through each cell in the matrix and randomly put a value
  22. between -40 and 40.  When I say RANDOMLY, I mean: A uniform random sample
  23. from the set [-40..40].  Here's what I tried (in psuedocode):
  24.  
  25.     FOR x:=0 TO 499
  26.       FOR y:=0 TO 69   /* Remember, Barry:  this is psuedocode... :)  */
  27.        c:=Rnd(80)
  28.        c:=c-40
  29.        array[x,y]:=c
  30.       ENDFOR
  31.     ENDFOR
  32.  
  33. Again, in psudocode, here's how I read it back out:
  34.  
  35.     FOR x:=0 to 499
  36.       FOR y:=0 to 69
  37.        IF array[x,y]<0 THEN WriteF('0') ELSE WriteF('1')
  38.       ENDFOR
  39.     ENDFOR
  40.  
  41. This should print out lines of length 70, containing a random sample from
  42. the boolean set [0,1]^70.  However, All I get are vectors containing all '1's.
  43. What gives?
  44.  
  45. Does anyone have a code solution for this, or some mathematics for a more
  46. statistically-pure uniform random sampling procedure?  This is gonna drive
  47. me up the wall!
  48.  
  49. To make things worse, I wrote a little program called test.e.  Here it is:
  50.  
  51. PROC main()
  52.   DEF a,x
  53.    For x:=0 to 10000
  54.      a:=Rnd(1000)
  55.     IF a<500 THEN WriteF('0') ELSE WriteF('1')
  56.   ENDFOR
  57. ENDPROC
  58.  
  59. Works just fine!!! I don't get it.  Barry, could this be a problem with how
  60. your array routines store integers (positive versus negative?)  I'm confused.
  61.  
  62. hopefully,
  63. mark